// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    syncClick() {
        console.log("cocos demo start syncClick");
        let ret = jsb.reflection.callStaticMethod(true, "entry/src/main/ets/util/InteractionDemo", "entry/syncFunction", "testParam");
        console.log(`cocos demo end syncClick, ret is ${ret}`);
    }

    asyncClick() {
        console.log("cocos demo start asyncClick");
        let ret = jsb.reflection.callStaticMethod(false, "entry/src/main/ets/util/InteractionDemo", "entry/asyncFunction", "testParam");
        console.log(`cocos demo end syncClick, ret is ${ret}`);
    }

    uiToWorkerClick() {
        console.log("cocos demo start uiToWorkerClick");
        jsb.reflection.callStaticMethod(true, "entry/src/main/ets/util/InteractionDemo", "entry/uiToWorkerFunction", "testParam");
        console.log("cocos demo end uiToWorkerClick");
    }
    
    arktsToCocosClick() {
        console.log("cocos demo start arktsToCocosClick");
        jsb.reflection.callStaticMethod(true, "entry/src/main/ets/util/InteractionDemo", "entry/arktsToCocosFunction", "testParam");
        console.log("cocos demo end arktsToCocosClick");
    }

    start () {

    }

    // update (dt) {}
}

globalThis.arktsToCocos = (a, b) => {
    return a+b;
}